﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Yugi.Client.Card;

namespace Yugi.Client
{
    public class TombModel 
    {
        public SupervisorModel YSupervisorModel { get; set; }
        public IInvoke Presenter { get; set; }
        private List<CardModel> List_Card = new List<CardModel>();
        public TombModel()
        {

        }
        public CardModel FindAsCardModel(int id)
        {
            return (List_Card.Find(p => p.YCard.ID == id));
        }
        public YBaseCard Find(int id)
        {
            return (List_Card.Find(p => p.YCard.ID == id)).YCard;
        }
        public bool Containt(int id)
        {
            foreach (var item in List_Card)
            {
                if (item.YCard.ID == id)
                    return true;
            }
            return false;
        }
        public void Add(CardModel card)
        {
            List_Card.Add(card);
            Presenter.Do(ClientMSG.ThemBaiVaoMo, card);
        }
        public void Remove(CardModel card)
        {
            List_Card.Remove(card);
            Presenter.Do(ClientMSG.XoaBaiTrongMo, card);
        }
        public void ReceiveMessageFromSupervisor(ClientMSG Message, params object[] param)
        {
            switch (Message)
            {

                default:
                    Presenter.Do(Message, param);
                    break;
            }
        }
        public void Reset()
        {
            this.List_Card.Clear();
        }
    }
}
